package com.xf.spring.factory;

import java.util.HashMap;
import java.util.Map;

/**
 * 静态工厂方法:直接调用类的静态方法
 */
public class StaticCarFactory {
    private static Map<String,Car> cars=new HashMap<String, Car>();
    static {
        cars.put("Aodi",new Car("Aodi",30));
        cars.put("Fute",new Car("Fute",40));
    }
    //静态工厂方法
    public static Car getCar(String name) {
        return cars.get(name);
    }

}
